/**
 * 请求时可能出现的错误
 */

class HttpException extends Error {
  constructor (msg = '服务器出错了', errCode = 10000, code = 400) {
    super()
    this.msg = msg
    this.errCode = errCode
    this.code = code
  }
}

class ParameterException extends HttpException {
  constructor (msg, errCode, code) {
    super()
    this.msg = msg || '参数错误'
    this.errCode = errCode || 10001
    this.code = 400
  }
}

class AuthFailedException extends HttpException {
  constructor (msg, errCode, code) {
    super()
    this.msg = msg || '授权失败'
    this.errCode = errCode || 10002
    this.code = code || 403
  }
}

class ArtNotExistException extends HttpException {
  constructor (msg, errCode, code) {
    super()
    this.msg = msg || '查询不到此数据1'
    this.errCode = errCode || 10003
    this.code = code || 405
  }
}

class ArtIsLikeException extends HttpException {
  constructor (msg, errCode, code) {
    super()
    this.msg = msg || '你已经点过赞了'
    this.errCode = errCode || 10004
    this.code = code || 406
  }
}

class ArtIsDisLikeException extends HttpException {
  constructor (msg, errCode, code) {
    super()
    this.msg = msg || '你已经取消点赞了'
    this.errCode = errCode || 10005
    this.code = code || 406
  }
}

module.exports = {
  HttpException,
  ParameterException,
  AuthFailedException,
  ArtNotExistException,
  ArtIsLikeException,
  ArtIsDisLikeException
}